﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace wwl.DataAccess.Migrations.Rbac
{
    /// <inheritdoc />
    public partial class Rbac_InitialCreate : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "rbac_tenant",
                columns: table => new
                {
                    id = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: false),
                    tenant_code = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: false),
                    tenant_name = table.Column<string>(type: "character varying(128)", maxLength: 128, nullable: false),
                    status = table.Column<string>(type: "character varying(20)", maxLength: 20, nullable: false),
                    created_time = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
                    updated_time = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
                    created_by = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: false),
                    remarks = table.Column<string>(type: "text", nullable: false),
                    is_deleted = table.Column<bool>(type: "boolean", nullable: false, defaultValue: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_rbac_tenant", x => x.id);
                    table.CheckConstraint("ck_tenant_status", "Status IN ('ENABLED', 'DISABLED')");
                });

            migrationBuilder.CreateIndex(
                name: "ix_rbac_tenant_tenant_code",
                table: "rbac_tenant",
                column: "tenant_code",
                unique: true);
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "rbac_tenant");
        }
    }
}
